var express = require('express')
var router = express.Router()

const { getById } = require('../db')

/**
 * 根据id获取单个用户数据
 *GET/user/id
 */
router.get('/:id', async (req, res) => {
  const { id } = req.params
  let sql = `select * from users where id='${id}'`
  const data = await getById(sql)
  res.send({
    code: 0,
    message: '获取单个用户成功',
    result: data,
  })
})

module.exports = router
